#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define BUFFER_SIZE  4

//自实现strcmp

int myStrcmp(const char *s1, const char *s2)
{
    if( s1 == NULL || s2 == NULL)//判断地址是否为空
    {
        perror("NULL");
        exit(-1);
    }
    while(*s1 != '\0' == *s2 != '\0')
    {
    
        if(*s1 > *s2 )
        {
            return 1;           

        }
        else if(*s1 == *s2)
        {
            return 0;
        }
        else
        {
            return -1;
        }
        
        s1++;//指针往后移，继续比较
        s2++;//

    }    
    //*s1 == '\0' || *s2 == '\0'
    /*退出while循环，一定以为着S1已经结束了或者S2已经结束了*/
   
    return *s1 - *s2;

}
int main()
{
    char *ptr1 = "zhangsan";
    char *ptr2 = "lisi";

    int ret = myStrcmp(ptr1, ptr2);//传字符串，传的是指针的地址
    
    printf("%d\n", ret);
    

}